package net.infamily.web.pages;

import net.infamily.web.secure.ProfilePage;

import org.apache.wicket.RestartResponseException;
import org.apache.wicket.authentication.AuthenticatedWebSession;
import org.apache.wicket.authentication.panel.SignInPanel;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;


public class LoginPage extends WebPage {

	public LoginPage() {
		add(new Label("message", "Welcome dude!"));
		add(new SignInPanel("signInPanel", true));
	}

	@Override
	protected void onBeforeRender() {
		super.onBeforeRender();
		if (AuthenticatedWebSession.get().isSignedIn()) {
			getRequestCycle().setRedirect(true);
			throw new RestartResponseException(ProfilePage.class);
		}
	}
}
